Skip to content

fix(sandboxpolicy): close the igbackend follow-ups of the NRI gate stack - #1229

Draft
matthyx wants to merge 4 commits into
mainfrom
omx/nri-fu-igbackend
Draft

matthyx wants to merge 4 commits into
mainfrom
omx/nri-fu-igbackend

Conversation

@matthyx

@matthyx matthyx commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-ups from the reviews of #1160 (S1) and #1162 (S2), stacked on #1178. Every change fails closed.

  • PID namespace proof: HostPIDNamespace now requires procRoot to be a procfs (statfs) before trusting the NSpid proof.
  • Gone-container cleanup (CodeRabbit feat(sandboxpolicy): pending-slot bindings and EPERM for Strict tracking faults #1160 4802841890): when deleting a gone container's entry fails, start and the move heal now fail instead of silently dropping the error. An entry that is already gone (ErrKeyNotExist) counts as deleted, so an in-place replacement racing the old instance does not fail the start. A failed bind no longer leaves a binding active with no kernel entry behind it.
  • Pending slot guard: start keeps an ErrCredUnrecorded binding only for the pending slot.
  • Tests: hadMove with ErrCredUnrecorded; the AdoptedPending fan-out across sections; the holds() exclusion; MarkPod on a record that still owes an unbind.
  • Doc comments.
  • 32-bit (GOARCH=386) is out of scope: node-agent ships only linux/amd64 and linux/arm64.

Validation:

  • vet; go test on ./pkg/sandboxpolicy/... and the enforcement packages in default, -tags startgate_vmtest and -race: all pass.
  • 11 mutations, each fails a test.
  • NOT-RUN: TestServiceReportsUnexpectedExporterExit (skipped here; fixed in the gate follow-up PR); VM qualification.

AI Review

Written with Claude Code (Claude Opus 5.5). One independent adversarial review: APPROVE with one MEDIUM (an already-deleted entry failed the start spuriously), fixed with a regression test and re-checked (APPROVE).

🤖 Generated with Claude Code

matthyx and others added 2 commits December 5, 2026 15:21
…stack

Follow-ups from the reviews of #1160 and #1162, all fail-closed.

- HostPIDNamespace requires procRoot to be a procfs (statfs) before the
  NSpid proof.
- A gone container whose entry delete fails no longer matches
  ErrContainerGone, so start and the move heal fail instead of
  silently dropping the cleanup (CodeRabbit #1160 4802841890); an
  entry that is already gone (ErrKeyNotExist) counts as deleted, and
  a failed bind no longer leaves a binding active with no entry.
- Start keeps an ErrCredUnrecorded binding only for the pending slot.
- Tests: hadMove with ErrCredUnrecorded, the AdoptedPending fan-out,
  the holds() exclusion, MarkPod on a record that owes an unbind.
- Type-only changes so the node-agent side builds for GOARCH=386
  (the IG fork still needs its own patch).
- Doc comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docs-exempt: internal fixes and tests in the unreleased NRI start gate stack
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@matthyx matthyx added the ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) label Dec 5, 2026
@coderabbitai

coderabbitai Bot commented Dec 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

node-agent ships only linux/amd64 and linux/arm64 (Makefile, release
workflows), and the IG fork does not build for 386, so the 32-bit type
changes add nothing. Restore the four files to their previous form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docs-exempt: reverts type-only changes, no behavior change on shipped platforms
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human review is needed because VM qualification was not run for start-gate correctness that depends on real host procfs and shared pinned-map behavior during replacement.

No open issues 🎉

What changed in this PR

This PR hardens the sandbox-policy NRI start gate, addressing follow-ups from #1160 and #1162 on top of #1178.

Changes:

  • Require procfs before accepting PID namespace evidence.
  • Propagate gone-container cleanup failures and restrict unrecorded startup bindings to pending slots.
  • Add regression tests, clarify comments, and adjust types for 386 compatibility; full 386 validation remains blocked.
File Description
pkg/​sandboxpolicy/​sections_adoptedpending_test.go Tests adopted-mark fan-out and section errors.
pkg/​sandboxpolicy/​integration/​podcgroup_test.go Routes synthetic namespace checks through the file-proof helper.
pkg/​sandboxpolicy/​integration/​podcgroup_linux.go Requires procfs and clarifies namespace guarantees.
pkg/​sandboxpolicy/​integration/​nrigate.go Updates namespace-validation comments only.
pkg/​sandboxpolicy/​integration/​nrigate_copilot8_test.go Tests rejection of crafted non-procfs directories.
pkg/​sandboxpolicy/​igbackend/​markpod_oldpod_test.go Tests marking while an old unbind remains pending.
pkg/​sandboxpolicy/​igbackend/​imageindex.go Handles filesystem magic values on 32-bit architectures.
pkg/​sandboxpolicy/​igbackend/​imageevidence.go Makes filesystem flag comparisons architecture-compatible.
pkg/​sandboxpolicy/​igbackend/​adoptedpending_test.go Tests exclusion of currently held cgroups.
pkg/​hostfimsensor/​v1/​fimsensor_fanotify.go Uses architecture-compatible timestamp conversion.
pkg/​ebpf/​gadgets/​common/​enforcement/​pending_followups_test.go Covers move retries, cleanup failures, and startup guards.
pkg/​ebpf/​gadgets/​common/​enforcement/​bindings.go Preserves cleanup errors and guards pending-slot recovery.
pkg/​config/​config.go Explicitly types the image-size default as int64.

Review effort: Balanced

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.025 0.025 +1.2%
Peak CPU (cores) 0.028 0.028 +2.0%
Peak CPU p95 (cores) 0.027 0.028 +3.5%
Avg Memory (MiB) 206.988 199.742 -3.5%
Peak Memory (MiB) 209.098 205.641 -1.7%
Dedup Effectiveness

No data available.

@matthyx
matthyx changed the base branch from omx/nri-s5b-followups to main December 5, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the NRI start-gate hardening changes.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) ai-reviewed-local

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants